class UserDetailController < ApplicationController
  include ApplicationHelper
  include UserDetailHelper
  
  def info
    id = params['id'].to_i
    
    getUserDetails id
    render :json => @hash_set_details
  end

  def edit
    set_form_setting
    names = getFirstEmployees.find(:conditions => ["EmployeeNumber = ?", params[:id]])
    @name = ""
    @name = names ? names[0].Name : ""
    @social_network = SocialNetwork.find(:first, :conditions => ["EmployeeNumber = ?", params[:id]])
  end

  def update
    set_form_setting
    @social_network = SocialNetwork.find(:first, :conditions => ["EmployeeNumber = ?", params[:id]])
    if @social_network.update_attributes(params[:social_network])
      render :inline => "<script type=\"text/javascript\">javascript:window.close();</script>"
    else
      names = getFirstEmployees.find({:only => [:Name], :conditions => ["EmployeeNumber = ?", params[:id]]})
      @name = ""
      @name = names ? names[0].Name : ""
      render "edit"
    end
  end

end
